<include file="public@header" />
<style>
	.chooseDN{
		display: none;
		position: absolute;
		z-index: 10;
		border: 1px solid #444;
		padding: 0.5rem;
		background: #fff;
		width: 100%;
	}
	.e-dn-list{
		cursor: pointer;
	}
</style>
</head>
<body>
	<div class="wrap">
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('manage/editPostFanpage')}">
			<div class="form-group">
				<label for="input-url" class="col-sm-2 control-label"><span class="form-required">*</span>粉丝页链接</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-url" name="url" value="{$fanpages.url}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-subordinate_id" class="col-sm-2 control-label"><span class="form-required">*</span>FB账号</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" value="{$fanpages.accountnumber}" name="" class="form-control" id="fbchose" oninput="showDnList(event)" autocomplete="off">
					<input type="hidden" value="" id="subordinate_id" name="subordinate_id">
					<div class="chooseDN"></div>
				</div>
			</div>
			<div class="form-group">
				<label for="input-in_bm" class="col-sm-2 control-label"><span class="form-required">*</span>BM</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-in_bm" name="in_bm" value="{$fanpages.in_bm}">
				</div>
			</div>
			<div class="col-sm-offset-2 col-sm-10">
				<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
			</div>
			<input type="hidden" class="form-control" id="input-id" name="id" value="{$fanpages.id}">
		</form>
	</div>
	<script>
		var fb = {$fb};
		console.log(fb);
		function showDnList(e){
            $(".chooseDN").css("display","block");
            $(".chooseDN").empty();
            var m = e.target.value;
            var arr = [];

            fb.forEach(function(item,i){
                if(item.accountnumber.indexOf(m)!=-1){
                    arr.push(item);
                }
            });

            var s = ``;
            arr.forEach(function(_item,j){
                s+= `<div class="e-dn-list" valtg="`+_item.id+`">`+_item.accountnumber+`</div>`;
            });
            $(".chooseDN").append(s);

            $(".e-dn-list").click(function(){
                var m =$(this).attr('valtg');
                var n =$(this).html();
                $("#fbchose").val(n);
                $("#subordinate_id").val(m);
                $(".chooseDN").css("display","none");
            	$(".chooseDN").empty();
            });
        }
	</script>
	<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
